package org.abc.uiCore.list
{

	import de.polygonal.ds.DLLNode;
	
	import org.abc.uiCore.vo.ListVo;


	/**
	 * @describe  	TileView
	 * @author  	Mr.zheng
	 * @website 	http://blog.sina.com.cn/zihua2007
	 * @time		2011-8-22 10:09
	 */
	public class TileView extends AbcListView
	{
		protected var _row:int=1;
		protected var _col:int=1;

		/* public function */

		/* override function */
		/**
		 *
		 * @param	list.row	行
		 * @param	list.col	列
		 * @param	list.align	0:	0,1,2,3,	(横向)
		 * 							4,5,6,7
		 * 						1:	0,2,4,6,	(竖向)
		 * 							1,3,5,7
		 */
		override public function setParams(listVo:ListVo):void
		{
			_row=listVo.row;
			_col=listVo.col;
			listVo.pageNum=_row * _col;
			/** super.setParams(listVo);最后将执行listVo.dispose()
			 * 	因此，该函数必须在最后执行*/
			super.setParams(listVo);
		}

		override protected function showCp():void
		{
			var node:DLLNode=_cpDll.head;
			var cp:AbcCP;
			var w:int=node.val.width;
			var h:int=node.val.height;
			var num:int;
			while (node)
			{
				cp=node.val as AbcCP;
				switch (_align)
				{
					case 0:
						cp.x=num % _col * (w + _gap) + _gap;
						cp.y=int(num / _col) * (h + _gap) + _gap;
						break;
					case 1:
						cp.x=int(num / _row) * (w + _gap) + _gap;
						cp.y=num % _row * (h + _gap) + _gap;
						break;
					default:
				}
				this.addChild(cp);
				node=node.next;
				num++;
			}

		}
	/* private function */
	}

}
